package acm;

import testing.*;
import java.util.Iterator;
import java.util.Scanner;
import java.util.ArrayList;

public class Combinatoria {

	Scanner sc = new Scanner(System.in);

	private String com;
	private ArrayList<String> listaComb;

	public Combinatoria(String def) {

		this.com = def;
		System.out.println(def);
		this.listaComb = new ArrayList<String>();
		
		
		boolean valido = true;


			for (int index = 0; index < com.length(); index++) {
				
				char aux = def.charAt(index);
				
				if (Character.isDigit(aux)) {

					valido = false;
					
				}

			}
			if (valido) {
				this.calcularCombinaciones();
				this.mostrarLista();
			}else{
				System.out.println("Error: isLetter = false");
			}
			
	
		
		

	}

	public void ingresarCombinacion() {

		boolean invalido = false;

		do {
			System.out.println("Ingrese combinacion");
			this.com = sc.nextLine();

			for (int index = 0; index < com.length(); index++) {
				
				char aux = this.com.charAt(index);
				
				if (!Character.isLetter(aux)) {

					invalido = true;
				}
				else{
					invalido = false;
				}

			}
			if (invalido) {
				System.out.println("Ingrese solo letras");
			}
			
		} while (invalido);

	}



	public void calcularCombinaciones() {

		this.listaComb = new ArrayList<String>();
		String combinacion = this.com;
		char[] comb = new char[this.com.length()];

		for (int cont = 0; cont < this.com.length(); cont++) {

			comb[cont] = combinacion.charAt(cont);

		}

		for (int index = 0; index < this.com.length() - 1; index++) {

			char[] combNueva = new char[this.com.length()];

			combNueva[this.com.length() - 1] = comb[0];

			for (int i = 0; i <= comb.length - 2; i++) {

				combNueva[i] = comb[i + 1];

			}

			String combS = "";
			for (int j = 0; j < comb.length; j++) {

				combS += combNueva[j];
			}

			this.listaComb.add(combS);
			comb = combNueva;

		}
	}

	public void mostrarLista() {

		Iterator<String> listaCIt = this.listaComb.iterator();

		while (listaCIt.hasNext()) {

			System.out.println(listaCIt.next());

		}
	}

}
